1. Field of the Invention
The present invention relates to a virtual machine technology, and more specifically, to a virtual machine system and a method for switching hardware devices thereof.
2. Description of Prior Art
In the process of existing virtualizations, there is a general virtual device platform, including virtual sound cards, virtual graphic cards and the like. Accesses to virtual devices in the virtual device platform by a Guest OS are directed to real devices through a Service OS or a Host OS by a Virtual Machine Monitor (VMM).
FIG. 1 is a schematic view of an existing Xen® virtual machine system. Xen® is Open Source software, released under the terms of the GNU General Public License, developed by the University of Cambridge. As shown in FIG. 1, the Xen® virtual machine system comprises a Guest OS, a Service OS, a Virtual Machine Monitor and hardware. The Guest OS is provided with applications and a driver module, and the Service OS is provided with a Device Model (DM) module and a driver module.
Hereinafter, the process of accessing the hardware by the Guest OS in the above Xen® virtual machine system is described with reference to FIG. 2.
Before the Guest OS initiates the access to the hardware, first, the Service OS, upon starting, scans a PCI bus, to allocate resources for the hardware, including IRQ, I/O, MMIO and the like. A virtual hardware platform is generated for the Guest OS by the DM module when the Guest OS is created.
The Guest OS, upon starting, scans a virtual PCI bus, to allocate resources for virtual hardware. After the Guest OS allocates the resources for the virtual hardware, device can be accessed.
The process of accessing the device by the Guest OS is described in the following.
When the Guest OS needs to access a hardware I/O space, it generates a corresponding I/O request by the virtual hardware drive module.
The VMM intercepts the I/O request generated by the drive module of the Guest OS, and sent it to the DM module in the Service OS.
The DM module analyzes the I/O request, and converts it into a corresponding invoking instruction. The invoking instruction is converted to I/O instructions by the drive module of the Service OS so as to invoke corresponding hardware.
After receiving a response from the hardware, the Service OS sends this response to the Guest OS through the VMM, so as to finish the access to the hardware by the Guest OS.
The process of accessing the hardware by the Guest OS is explained above in the Xen® virtual machine system as an example. For other virtual machine systems, such as Vmware virtual machine system, the similar access process is performed, except that a Host OS plays the role of the Service OS in the Xen® virtual machine system.
Because it is impossible for the existing virtual machine systems to solve the problem of sharing the real hardware devices by a plurality of operating systems, in the above general virtualization platform, the virtualized devices are consistent regardless of the real device platforms. Although this applies to various Guest OSs, the following problems will arise:    1) The hardware devices displayed by the virtual machine system are not consistent with the real hardware devices, and users cannot see the real hardware devices.    2) Further, some properties of the real hardware cannot be used, such as hardware accelerating property of graphical cards, new standard of USB, and advanced properties of sound cards.    3) Because it is only possible for the Guest OS to access the hardware by the VMM and the Service OS, there additionally exist corresponding intermediate processes, impacting the performance of accessing the hardware.    4) Because there is provided no corresponding management and control for hardware properties, the properties of the real hardware are not completely exploited.